<template>
  <rx-layout>
    <div slot="center" style>
      <rx-fit>
        <div slot="toolheader" foldheader="true" foldbtn="false" border="false">
          <span class="search-btn-box">
                <span class="search-btn" @click="searchshow"><i class="iconfont iconguolv"></i>{{  $ti18('rxList.leachBtn', '过滤') }}</span>
           </span>
        </div>
        <div slot="searchbar" btnalign="right"  v-if="fitSearch" @search="search" @cancel="cancel" @close="close">
          <a-form layout="vertical">
                <a-form-item :label="i18n('form.listName','列表名称')">
                    <a-input :placeholder="i18n('form.listName','请输入列表名称','input')" v-model="queryParam.Q_LIST_NAME__S_LK"/>
                </a-form-item>
                <a-form-item :label="i18n('form.subject','记录标题')">
                  <a-input :placeholder="i18n('form.listName','请输入记录标题','input')" v-model="queryParam.Q_SUBJECT__S_LK"/>
                </a-form-item>
                <a-form-item :label="i18n('form.subject','导入状态')">
                    <a-select v-model="queryParam.Q_STATUS__S_LK">
                      <a-select-option value="0">{{i18n('statusMap.fail','失败')}}</a-select-option>
                      <a-select-option value="1">{{i18n('statusMap.success','成功')}}</a-select-option>
                      <a-select-option value="2">{{i18n('statusMap.importing','正在导入')}}</a-select-option>
                    </a-select>
                </a-form-item>
          </a-form>
        </div>
        <rx-grid
                ref="table"
                :allowRowSelect="true"
                :multiSelect="true"
                :columns="columns"
                :defaultPageSize="10"
                url="/api-form/form/core/formImportRecord/query"
                :queryParam="queryParam"
                data-field="result.data"
                :pageSizeOptions="['10','30','40']"
                id-field="id"
                @selectChange="onSelectChange"
        >
          <span slot="status" slot-scope="{text,record}">
            <a-tag :color="statusMap[text].color">
              <span>{{ statusMap[text].text }}</span>
            </a-tag>
          </span>
          <span slot="action" slot-scope="{ text, record }" class="actionIcons">
                    <span  @click="detail(record)">{{i18n("list.detail",'详情')}}</span>
          </span>
        </rx-grid>
      </rx-fit>
    </div>
  </rx-layout>
</template>

<script>
  import FormImportRecordApi from '@/api/form/core/formImportRecord'
  import FormImportRecordEdit from './FormImportRecordEdit'
  import {BaseList,RxFit,RxGrid } from "@lowcode/jpaas-common-lib";
  export default {
    name: 'FormImportRecordList',
    mixins: [BaseList],
    components: {
      RxFit
    },
    data() {
      return {
        columns: [
          {
            title: this.$ti18('rxList.index','序号'),
            type: 'indexColumn',
            width: 50,
            dataIndex: 'serial',
            scopedSlots: {customRender: 'serial'}
          },
          {title: this.i18n('form.listName','列表名称'), dataIndex: 'listName', width: 100},
          {title: this.i18n('form.status','导入状态'), dataIndex: 'status', width: 50,scopedSlots: {customRender: 'status'}},
          {title: this.i18n('form.subject','记录标题'), dataIndex: 'subject', width: 250},
          {title: this.i18n('form.createByName','创建人名称'), dataIndex: 'createByName', width: 50},
          {title: this.i18n('form.createTime','创建时间'), dataIndex: 'createTime', width:100},
          {title: this.$ti18('rxList.action','操作'), width: 50, dataIndex: 'action', scopedSlots: {customRender: 'action'}}
        ],
        component:FormImportRecordEdit,
        comment: this.i18n('list.comment','Excel导入记录(异步)'),
        fitSearch:false,
          statusMap: {
              1: {color: 'green', text: this.i18n('statusMap.success','成功')},
              0: {color: 'red', text: this.i18n('statusMap.fail','失败')},
              2: {color: 'orange', text: this.i18n('statusMap.importing','正在导入')}
          },
      }
    },
    methods:{
      i18n(name,text,key){
          return this.$ti18(name,text,"FormImportRecord",key);
      },
      delById(ids){
        return FormImportRecordApi.del({ ids: ids.join(',') });
      },
      getListByParams(parameter){
        return FormImportRecordApi.query(parameter)
      }

    }
  }
</script>
<style scoped>
  .table-operator {
    padding:4px;
  }
  .table-operator button {
    margin:2px;
  }
</style>

